package com.example.rss_reder;

import android.util.Log;

public class List {
	
	private String name;
	private String link;
	private String img;
	private String sub;
	private String date;
	
	List(String name, String link, String sub, String date){
		this.name = name;
		this.link = link;
		this.sub = sub;
		this.date = date;
	}
	List(String name, String link, String img, String date, int i){
		this.name = name;
		this.link = link;
		this.img = img;
		this.date = date;
	}
	
	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public String getImg(int num) {
		return img;
	}
	
	public String getImg() {
				if((sub.indexOf("src=\"")==-1)&&(sub.indexOf("src=\"")==-1)){
					img=null;
				}else if(!(sub.substring(0,1).equals("<"))){
					img=null;
				}else if(sub.indexOf("src=\'")!=-1){
					img = sub.substring(sub.indexOf("src=\'")+5);
					img = img.substring(0,img.indexOf("\'"));
					if(!(img.substring(0,4).equals("http"))){
						img = "http:"+img;
					}
				}else{
					img = sub.substring(sub.indexOf("src=\"")+5);
					img = img.substring(0,img.indexOf("\""));
					if(!(img.substring(0,4).equals("http"))){
						img = "http:"+img;
					}
				}
		return img;
	}

	public void setImg(String img) {
		this.img = img;
	}

	public String getSub() {
		String d;
		sub = "<html><head>"+
			  "<meta http-equiv=\"Content-Type\" "+
			  "content=\"text/html; charset=UTF-8\">"+
			  "</head>"+
			  sub+"</body></html>";
		
		if(sub.substring(sub.indexOf("src=\"")+5,sub.indexOf("src=\"")+9).equals("http")){
			d=sub;
		}else{
			d = sub.substring(0,sub.indexOf("src=\"")+5)+
					"http:"+
					sub.substring(sub.indexOf("src=\"")+5);
		}

		return d;
//		return sub;
	}

	public void setSub(String sub) {
		this.sub = sub;
	}

	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getLink() {
		if(link!=null){
		if(link.length()>3){
		if(link.subSequence(0, 3).equals("url"))
			link=link.substring(4);
		}
		}
		return link;
	}
	public void setLink(String link) {
		this.link = link;
	}

}
